import { http } from '@/utils/http/axios';
//axios
import axios from "../myAxios.js"
//获取table
export function getTableList(params) {

  //axios 在这里
  return http.request({
    url: '/table/list',
    method: 'get',
    params,
  });

}

export async function getTableListAboutTeacher(params) {

  const res = await axios.get('/user/select', { params })
  return res.data.result


}

export async function getTableListAboutselectByName(params) {

  console.log("selectByNamelailo - params", params)

  const res = await axios.post('/user/selectByName', { ...params })

  console.log("user/selectByName", res)

  console.log("result", res.data.result)

  return res.data.result


}

export async function getTableListAboutStudent(params) {


  const res = await axios.get('/user/select', { params })
  return res.data.result


}

export async function getTableListAboutLabAdmin(params) {


  const res = await axios.get('/user/select', { params })
  return res.data.result


}

export async function getTableListAboutDiffernetPeopleApi(params) {


  const res = await axios.get('/user/select', { params })
  return res.data.result


}


export async function handleResetPasswordApi(params) {

  const res = await axios.post('/user/resetPwd/', {
    account: params.account
  })

  if (res.data.code == 200) {
    window['$message'].success('重置密码成功');
  } else {
    window['$message'].error(res.data.message);
  }
  return res.data.result


}

//获取所有学期
export async function getAllTerm() {
  const res = await axios.get('/admin/get/term', {
    //写死了 这里不需要做分页 但是接口写了分页
    params: {
      pageNum: 1,
      pageSize: 999
    }
  })

  // console.log("getAllTerm()",res)

  return res.data.result

}


export async function uploadFileApi(params) {

  const res = await axios({
    url: "/user/register",
    method: "POST",
    data: params.data,
  })
  if (res.data.code == 200) {
    window['$message'].success('上传成功');
  } else {
    window['$message'].error(res.data.message);
  }

  return res.data.result

}